import { getApi, postApi } from "../../config/request";
import { AxiosPromise } from "axios";

/**
 * 获取运维角色信息
 *
 */
// 查询角色列表-运维使用
export const reqPreserveList = (params: object = {}): AxiosPromise => {
  return getApi("/system/role/query_list_all", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 创建层级默认角色-运维使用
export const reqPreserveCreate = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/save", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 修改角色-运维使用
export const reqPreserveModify = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/modify", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 删除角色-运维使用
export const reqPreserveDelete = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/delete", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 获取所有单位级别
export const reqUnitLevelList = (params: object = {}): AxiosPromise => {
  return getApi("/system/unit_level/list", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 保存角色资源对应关系
export const reqResourceRoleRelation = (params: object = {}): AxiosPromise => {
  return postApi("/system/role_resource/save", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

/**
 * 获取单位角色信息
 *
 */

// 查询角色详情
export const reqRoleInfo = (params: object = {}): AxiosPromise => {
  return getApi("/system/role/get_one", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};
// 查询角色列表
export const reqRoleList = (params: object = {}): AxiosPromise => {
  return getApi("/system/role/query_list", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 查询角色对应资源
export const reqRoleSource = (params: object = {}): AxiosPromise => {
  return getApi("/system/role_resource/get_resource", {
    params,
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
  });
};

// 修改角色-单位使用
export const reqModifyRole = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/modifyForUnit", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};
// 创建角色-单位使用
export const reqAddRole = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/saveForUnit", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};

// 删除角色-单位使用
export const reqDeleteRole = (params: object = {}): AxiosPromise => {
  return postApi("/system/role/deleteForUnit", params, {
    "Content-Type": "application/x-www-form-urlencoded",
  });
};
